/**
 * ClassName: O2TwoDimensionalArray
 * Package: PACKAGE_NAME
 * Description:
 *
 * @Author 糕糕
 * @Create 2024-01-28 21:26
 * @Version 1.0
 */
public class O2TwoDimensionalArray {
    public static void main(String[] args) {
        //1.数组的声明与初始化
        //静态初始化
        int[][] arr1 = {{1, 2, 3}, {4, 5, 6}};
        //动态初始化
        int[][] arr2 = new int[2][3];
        arr2 = new int[][]{{7, 8, 9}, {10, 11, 12}};


        //其他写法
        int[][] arr3 = {{1, 2, 3}, {4, 5, 6}};

        int[][] arr4 = {{7, 8, 9}, {10, 11, 12}};

        //2.数组元素的调用
        int arrItem = arr1[0][2];
        System.out.println(arrItem);

        //3.数组的长度
        System.out.println(arr1.length);
        System.out.println(arr1[0].length);


        //4.如何遍历数组
        for (int i = 0; i < arr1.length; i++) {
            for (int j = 0; j < arr1[i].length; j++) {
                System.out.print(arr1[i][j]);
                System.out.print("\t");
            }
            System.out.println();
        }

        //数组元素的默认初始化值

        /*
         * 外层元素，默认存储地址值
         * 内层元素，默认与以为数组元素的不同类型的默认值规定相同
         * */

        double[][] d1 = new double[4][4];
//        method(d1);
        /*
        0.0	0.0	0.0	0.0
        0.0	0.0	0.0	0.0
        0.0	0.0	0.0	0.0
        0.0	0.0	0.0	0.0
        */

        int[][] i1 = new int[4][4];
//        method(i1);

        /*
        0	0	0	0
        0	0	0	0
        0	0	0	0
        0	0	0	0
         */

        short[][] s1 = new short[4][4];
//        method(s1);
          /*
        0	0	0	0
        0	0	0	0
        0	0	0	0
        0	0	0	0
         */

        char[][] c1 = new char[4][4];
//        method(c1);
        /*空格*/


        boolean[][] b1 = new boolean[4][4];
        method(b1);
        /*
false	false	false	false
false	false	false	false
false	false	false	false
false	false	false	false
        * */

        String[][] s2 = new String[4][4];
//        method(s2);

        /*
            null	null	null	null
            null	null	null	null
            null	null	null	null
            null	null	null	null
          */
    }


    int[][] arr5 = new int[3][];
    //外层元素，默认存储null 内层元素不存在的，如果调用会报错 nullpointerexception

    public static void method(boolean[][] arr) {
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                System.out.print(arr[i][j]);
                System.out.print("\t");
            }
            System.out.println();
        }
    }
}


class ArrayExer03 {
    public static void main(String[] args) {
        //定义二维employees数组：
        String[][] employees = {
                {"10", "1", "段 誉", "22", "3000"},
                {"13", "2", "令狐冲", "32", "18000", "15000", "2000"},
                {"11", "3", "任我行", "23", "7000"},
                {"11", "4", "张三丰", "24", "7300"},
                {"12", "5", "周芷若", "28", "10000", "5000"},
                {"11", "6", "赵 敏", "22", "6800"},
                {"12", "7", "张无忌", "29", "10800", "5200"},
                {"13", "8", "韦小宝", "30", "19800", "15000", "2500"},
                {"12", "9", "杨 过", "26", "9800", "5500"},
                {"11", "10", "小龙女", "21", "6600"},
                {"11", "11", "郭 靖", "25", "7100"},
                {"12", "12", "黄 蓉", "27", "9600", "4800"}
        };

        System.out.println("员工类型\t编号\t姓名\t\t年龄\t薪资\t\t奖金\t\t股票");

        for (int i = 0; i < employees.length; i++) {
            //"10"代表普通职员，"11"代表程序员，"12"代表设计师，"13"代表架构师
            String employeeType = employees[i][0];
            switch (employeeType) {
                case "10":
                    System.out.print("普通职员\t");
                    break;
                case "11":
                    System.out.print("程序员\t");
                    break;
                case "12":
                    System.out.print("设计师\t");
                    break;
                case "13":
                    System.out.print("架构师\t");
                    break;
            }

            for (int j = 1; j < employees[i].length; j++) {
                System.out.print(employees[i][j] + "\t");
            }
            System.out.println();
        }

    }
}

